/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package se.sll.engagemangsindex.ws;

import java.text.SimpleDateFormat;
import java.util.Date;
import javax.ejb.EJB;
import javax.jws.WebService;
import lombok.extern.slf4j.Slf4j;
import riv.itintegration.monitoring.pingforconfiguration._1.rivtabp21.PingForConfigurationResponderInterface;
import riv.itintegration.monitoring.pingforconfigurationresponder._1.PingForConfigurationType;
import riv.itintegration.monitoring.pingforconfigurationresponder._1.PingForConfigurationResponseType;
import se.sll.engagemangsindex.ejb.EngagementEjb;

/**
 *
 * @author khaleddaham
 */
@WebService(endpointInterface = "riv.itintegration.monitoring.pingforconfiguration._1.rivtabp21.PingForConfigurationResponderInterface",
serviceName = "PingForConfiguration")
@Slf4j
public class PingWSImpl implements PingForConfigurationResponderInterface {

    @EJB
    private EngagementEjb engagementEjb;
    private static final String VERSION = "1.0";

    /**
     *
     * @param message
     * @param configurationType
     * @return
     */
    @Override
    public PingForConfigurationResponseType pingForConfiguration(String message, PingForConfigurationType configurationType) {
        PingForConfigurationResponseType response = new PingForConfigurationResponseType();
        engagementEjb.pingDatabase();
        Date now = new Date();
        SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
        response.setPingDateTime(format.format(now).toString());
        response.setVersion(VERSION);
        return response;
    }
    
    /**
     * 
     * @param mock 
     */
    protected void setEngagementEjb(EngagementEjb mock) {
        this.engagementEjb = mock;
    }
}
